const launches = new Map();
// 数据⽰例
const launch = {
    flightNumber: 100,
    mission: 'Kepler Exploration X',
    rocket: 'Explorer IS1',
    launchDate: new Date('December 27, 2030'),
    target: 'Kepler-442 b',
    customer: ['GKD', 'NASA'],
    upcoming: true,
    success: true,
};
launches.set(launch.flightNumber, launch);
function existsLaunchWithId(launchId) {
 return launches.has(launchId);
}
function addNewLaunch(launch) {
    latestFlightNumber++;
    launches.set(
    latestFlightNumber,
    Object.assign(launch, {
    success: true,
    upcoming: true,
    customers: ['GKD', 'NASA'],
    flightNumber: latestFlightNumber,
 })
 );
}
function abortLaunchById(launchId) {
    const aborted = launches.get(launchId);
    aborted.upcoming = false;
    aborted.success = false;
    return aborted;
}

function getAllLaunches(){
    return Array.from(launches.values());
}
module.exports = {
    existsLaunchWithId,
    getAllLaunches,
    addNewLaunch,
    abortLaunchById,
};